package com.hoshiicloud.common.exception;

/**
 * 业务异常
 *
 * @author Tortoise
 * @since 2018-08-23
 */
public class ServiceException extends RuntimeException {

	private static final long serialVersionUID = 1L;

	/**
	 * 错误
	 */
	private CommonError error;

	public ServiceException(CommonError error) {
		super(error.getMsg());
		this.error = error;
	}

	public ServiceException(String errorMsg) {
		super(errorMsg);
		this.error = CommonError.error(errorMsg);
	}

	public ServiceException(CommonError error, Throwable cause) {
		super(error.getMsg(), cause);
		this.error = error;
	}

	/**
	 * 获取错误
	 *
	 * @return 错误
	 */
	public CommonError getError() {
		return error;
	}

}
